home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Technology Seed / Jan. '98 ATS.toast / QuickTime™ 3.0b11 / QTPublicInterfaces / CIncludes / Resources.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-12  |  12.0 KB  |  422 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Resources.h
  3.  
  4.      Contains:    Resource Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    QuickTime 3.0 Beta
  8.  
  9.      Copyright:    © 1985-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __RESOURCES__
  19. #define __RESOURCES__
  20.  
  21. #ifndef __MACTYPES__
  22. #include <MacTypes.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27. #ifndef __FILES__
  28. #include <Files.h>
  29. #endif
  30.  
  31.  
  32.  
  33. #if PRAGMA_ONCE
  34. #pragma once
  35. #endif
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT
  42. #pragma import on
  43. #endif
  44.  
  45. #if PRAGMA_STRUCT_ALIGN
  46.     #pragma options align=mac68k
  47. #elif PRAGMA_STRUCT_PACKPUSH
  48.     #pragma pack(push, 2)
  49. #elif PRAGMA_STRUCT_PACK
  50.     #pragma pack(2)
  51. #endif
  52.  
  53.  
  54. enum {
  55.     resSysHeap                    = 64,                            /*System or application heap?*/
  56.     resPurgeable                = 32,                            /*Purgeable resource?*/
  57.     resLocked                    = 16,                            /*Load it in locked?*/
  58.     resProtected                = 8,                            /*Protected?*/
  59.     resPreload                    = 4,                            /*Load in on OpenResFile?*/
  60.     resChanged                    = 2,                            /*Resource changed?*/
  61.     mapReadOnly                    = 128,                            /*Resource file read-only*/
  62.     mapCompact                    = 64,                            /*Compact resource file*/
  63.     mapChanged                    = 32                            /*Write map out at update*/
  64. };
  65.  
  66.  
  67. enum {
  68.     resSysRefBit                = 7,                            /*reference to system/local reference*/
  69.     resSysHeapBit                = 6,                            /*In system/in application heap*/
  70.     resPurgeableBit                = 5,                            /*Purgeable/not purgeable*/
  71.     resLockedBit                = 4,                            /*Locked/not locked*/
  72.     resProtectedBit                = 3,                            /*Protected/not protected*/
  73.     resPreloadBit                = 2,                            /*Read in at OpenResource?*/
  74.     resChangedBit                = 1,                            /*Existing resource changed since last update*/
  75.     mapReadOnlyBit                = 7,                            /*is this file read-only?*/
  76.     mapCompactBit                = 6,                            /*Is a compact necessary?*/
  77.     mapChangedBit                = 5                                /*Is it necessary to write map?*/
  78. };
  79.  
  80.  
  81. enum {
  82.     kResFileNotOpened            = -1,                            /*ref num return as error when opening a resource file*/
  83.     kSystemResFile                = 0                                /*this is the default ref num to the system file*/
  84. };
  85.  
  86.  
  87. typedef CALLBACK_API( void , ResErrProcPtr )(OSErr thErr);
  88. /*
  89.     WARNING: ResErrProcPtr uses register based parameters under classic 68k
  90.              and cannot be written in a high-level language without 
  91.              the help of mixed mode or assembly glue.
  92. */
  93. typedef REGISTER_UPP_TYPE(ResErrProcPtr)                         ResErrUPP;
  94. enum { uppResErrProcInfo = 0x00001002 };                         /* register no_return_value Func(2_bytes:D0) */
  95. #define NewResErrProc(userRoutine)                                 (ResErrUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppResErrProcInfo, GetCurrentArchitecture())
  96. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  97.     #pragma parameter CallResErrProc(__A0, __D0)
  98.     void CallResErrProc(ResErrUPP routine, OSErr thErr) = 0x4E90;
  99. #else
  100.     #define CallResErrProc(userRoutine, thErr)                     CALL_ONE_PARAMETER_UPP((userRoutine), uppResErrProcInfo, (thErr))
  101. #endif
  102. #if !TARGET_OS_MAC
  103. typedef OSErr (*ResourceEndianFilterPtr)(Handle theResource, Boolean currentlyNativeEndian);
  104. #endif  /*  !TARGET_OS_MAC */
  105.  
  106. EXTERN_API( short )
  107. InitResources                    (void)                                                        ONEWORDINLINE(0xA995);
  108.  
  109. EXTERN_API( void )
  110. RsrcZoneInit                    (void)                                                        ONEWORDINLINE(0xA996);
  111.  
  112. EXTERN_API( void )
  113. CloseResFile                    (short                     refNum)                                ONEWORDINLINE(0xA99A);
  114.  
  115. EXTERN_API( OSErr )
  116. ResError                        (void)                                                        ONEWORDINLINE(0xA9AF);
  117.  
  118. EXTERN_API( short )
  119. CurResFile                        (void)                                                        ONEWORDINLINE(0xA994);
  120.  
  121. EXTERN_API( short )
  122. HomeResFile                        (Handle                 theResource)                        ONEWORDINLINE(0xA9A4);
  123.  
  124. EXTERN_API( void )
  125. CreateResFile                    (ConstStr255Param         fileName)                            ONEWORDINLINE(0xA9B1);
  126.  
  127. EXTERN_API( short )
  128. OpenResFile                        (ConstStr255Param         fileName)                            ONEWORDINLINE(0xA997);
  129.  
  130. EXTERN_API( void )
  131. UseResFile                        (short                     refNum)                                ONEWORDINLINE(0xA998);
  132.  
  133. EXTERN_API( short )
  134. CountTypes                        (void)                                                        ONEWORDINLINE(0xA99E);
  135.  
  136. EXTERN_API( short )
  137. Count1Types                        (void)                                                        ONEWORDINLINE(0xA81C);
  138.  
  139. EXTERN_API( void )
  140. GetIndType                        (ResType *                theType,
  141.                                  short                     index)                                ONEWORDINLINE(0xA99F);
  142.  
  143. EXTERN_API( void )
  144. Get1IndType                        (ResType *                theType,
  145.                                  short                     index)                                ONEWORDINLINE(0xA80F);
  146.  
  147. EXTERN_API( void )
  148. SetResLoad                        (Boolean                 load)                                ONEWORDINLINE(0xA99B);
  149.  
  150. EXTERN_API( short )
  151. CountResources                    (ResType                 theType)                            ONEWORDINLINE(0xA99C);
  152.  
  153. EXTERN_API( short )
  154. Count1Resources                    (ResType                 theType)                            ONEWORDINLINE(0xA80D);
  155.  
  156. EXTERN_API( Handle )
  157. GetIndResource                    (ResType                 theType,
  158.                                  short                     index)                                ONEWORDINLINE(0xA99D);
  159.  
  160. EXTERN_API( Handle )
  161. Get1IndResource                    (ResType                 theType,
  162.                                  short                     index)                                ONEWORDINLINE(0xA80E);
  163.  
  164. EXTERN_API( Handle )
  165. GetResource                        (ResType                 theType,
  166.                                  short                     theID)                                ONEWORDINLINE(0xA9A0);
  167.  
  168. EXTERN_API( Handle )
  169. Get1Resource                    (ResType                 theType,
  170.                                  short                     theID)                                ONEWORDINLINE(0xA81F);
  171.  
  172. EXTERN_API( Handle )
  173. GetNamedResource                (ResType                 theType,
  174.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA9A1);
  175.  
  176. EXTERN_API( Handle )
  177. Get1NamedResource                (ResType                 theType,
  178.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA820);
  179.  
  180. EXTERN_API( void )
  181. MacLoadResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9A2);
  182.  
  183. EXTERN_API( void )
  184. ReleaseResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9A3);
  185.  
  186. EXTERN_API( void )
  187. DetachResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA992);
  188.  
  189. EXTERN_API( short )
  190. UniqueID                        (ResType                 theType)                            ONEWORDINLINE(0xA9C1);
  191.  
  192. EXTERN_API( short )
  193. Unique1ID                        (ResType                 theType)                            ONEWORDINLINE(0xA810);
  194.  
  195. EXTERN_API( short )
  196. GetResAttrs                        (Handle                 theResource)                        ONEWORDINLINE(0xA9A6);
  197.  
  198. EXTERN_API( void )
  199. GetResInfo                        (Handle                 theResource,
  200.                                  short *                theID,
  201.                                  ResType *                theType,
  202.                                  Str255                 name)                                ONEWORDINLINE(0xA9A8);
  203.  
  204. EXTERN_API( void )
  205. SetResInfo                        (Handle                 theResource,
  206.                                  short                     theID,
  207.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA9A9);
  208.  
  209. EXTERN_API( void )
  210. AddResource                        (Handle                 theData,
  211.                                  ResType                 theType,
  212.                                  short                     theID,
  213.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA9AB);
  214.  
  215. EXTERN_API( long )
  216. GetResourceSizeOnDisk            (Handle                 theResource)                        ONEWORDINLINE(0xA9A5);
  217.  
  218. EXTERN_API( long )
  219. GetMaxResourceSize                (Handle                 theResource)                        ONEWORDINLINE(0xA821);
  220.  
  221. EXTERN_API( long )
  222. RsrcMapEntry                    (Handle                 theResource)                        ONEWORDINLINE(0xA9C5);
  223.  
  224. EXTERN_API( void )
  225. SetResAttrs                        (Handle                 theResource,
  226.                                  short                     attrs)                                ONEWORDINLINE(0xA9A7);
  227.  
  228. EXTERN_API( void )
  229. ChangedResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9AA);
  230.  
  231. EXTERN_API( void )
  232. RemoveResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9AD);
  233.  
  234. EXTERN_API( void )
  235. UpdateResFile                    (short                     refNum)                                ONEWORDINLINE(0xA999);
  236.  
  237. EXTERN_API( void )
  238. WriteResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9B0);
  239.  
  240. EXTERN_API( void )
  241. SetResPurge                        (Boolean                 install)                            ONEWORDINLINE(0xA993);
  242.  
  243. EXTERN_API( short )
  244. GetResFileAttrs                    (short                     refNum)                                ONEWORDINLINE(0xA9F6);
  245.  
  246. EXTERN_API( void )
  247. SetResFileAttrs                    (short                     refNum,
  248.                                  short                     attrs)                                ONEWORDINLINE(0xA9F7);
  249.  
  250. EXTERN_API( short )
  251. OpenRFPerm                        (ConstStr255Param         fileName,
  252.                                  short                     vRefNum,
  253.                                  SInt8                     permission)                            ONEWORDINLINE(0xA9C4);
  254.  
  255. EXTERN_API( Handle )
  256. RGetResource                    (ResType                 theType,
  257.                                  short                     theID)                                ONEWORDINLINE(0xA80C);
  258.  
  259. /*
  260.     Note:     The HOpenResFile trap was not implemented until System 7.  If you want to call HOpenResFile
  261.             while running on System 6 machines, then define USE_HOPENRESFILE_GLUE and link with
  262.             Interface.o which contains glue to implement HOpenResFile on pre-System 7 machines.
  263. */
  264. #ifdef USE_HOPENRESFILE_GLUE
  265. EXTERN_API( short )
  266. HOpenResFile                    (short                     vRefNum,
  267.                                  long                     dirID,
  268.                                  ConstStr255Param         fileName,
  269.                                  SInt8                     permission);
  270.  
  271. #else
  272. EXTERN_API( short )
  273. HOpenResFile                    (short                     vRefNum,
  274.                                  long                     dirID,
  275.                                  ConstStr255Param         fileName,
  276.                                  SInt8                     permission)                            ONEWORDINLINE(0xA81A);
  277.  
  278. #endif  /*  defined(USE_HOPENRESFILE_GLUE)  */
  279.  
  280. /*
  281.     Note:     The HCreateResFile trap was not implemented until System 7.  If you want to call HCreateResFile
  282.             while running on System 6 machines, then define USE_HCREATERESFILE_GLUE and link with
  283.             Interface.o which contains glue to implement HCreateResFile on pre-System 7 machines.
  284. */
  285. #ifdef USE_HCREATERESFILE_GLUE
  286. EXTERN_API( void )
  287. HCreateResFile                    (short                     vRefNum,
  288.                                  long                     dirID,
  289.                                  ConstStr255Param         fileName);
  290.  
  291. #else
  292. EXTERN_API( void )
  293. HCreateResFile                    (short                     vRefNum,
  294.                                  long                     dirID,
  295.                                  ConstStr255Param         fileName)                            ONEWORDINLINE(0xA81B);
  296.  
  297. #endif  /*  defined(USE_HCREATERESFILE_GLUE)  */
  298.  
  299. EXTERN_API( short )
  300. FSpOpenResFile                    (const FSSpec *            spec,
  301.                                  SignedByte             permission)                            TWOWORDINLINE(0x700D, 0xAA52);
  302.  
  303. EXTERN_API( void )
  304. FSpCreateResFile                (const FSSpec *            spec,
  305.                                  OSType                 creator,
  306.                                  OSType                 fileType,
  307.                                  ScriptCode             scriptTag)                            TWOWORDINLINE(0x700E, 0xAA52);
  308.  
  309. EXTERN_API( void )
  310. ReadPartialResource                (Handle                 theResource,
  311.                                  long                     offset,
  312.                                  void *                    buffer,
  313.                                  long                     count)                                TWOWORDINLINE(0x7001, 0xA822);
  314.  
  315. EXTERN_API( void )
  316. WritePartialResource            (Handle                 theResource,
  317.                                  long                     offset,
  318.                                  const void *            buffer,
  319.                                  long                     count)                                TWOWORDINLINE(0x7002, 0xA822);
  320.  
  321. EXTERN_API( void )
  322. SetResourceSize                    (Handle                 theResource,
  323.                                  long                     newSize)                            TWOWORDINLINE(0x7003, 0xA822);
  324.  
  325. EXTERN_API( Handle )
  326. GetNextFOND                        (Handle                 fondHandle)                            TWOWORDINLINE(0x700A, 0xA822);
  327.  
  328. #if !TARGET_OS_MAC
  329.  
  330. EXTERN_API ( OSErr )
  331.     RegisterResourceEndianFilter(ResType                theType,
  332.                                 ResourceEndianFilterPtr theFilterProc);
  333.  
  334. #endif  /*  !TARGET_OS_MAC */
  335.  
  336. /* Use TempInsertROMMap to force the ROM resource map to be
  337.    inserted into the chain in front of the system. Note that
  338.    this call is only temporary - the modified resource chain
  339.    is only used for the next call to the resource manager.
  340.    See IM IV 19 for more information.
  341. */
  342. EXTERN_API( void )
  343. TempInsertROMMap                (Boolean                 tempResLoad)                        FIVEWORDINLINE(0x70FF, 0x4A1F, 0x56C0, 0x31C0, 0x0B9E);
  344.  
  345.  
  346. #if CGLUESUPPORTED
  347. EXTERN_API_C( Handle )
  348. getnamedresource                (ResType                 theType,
  349.                                  const char *            name);
  350.  
  351. EXTERN_API_C( Handle )
  352. get1namedresource                (ResType                 theType,
  353.                                  const char *            name);
  354.  
  355. EXTERN_API_C( short )
  356. openrfperm                        (const char *            fileName,
  357.                                  short                     vRefNum,
  358.                                  char                     permission);
  359.  
  360. EXTERN_API_C( short )
  361. openresfile                        (const char *            fileName);
  362.  
  363. EXTERN_API_C( void )
  364. createresfile                    (const char *            fileName);
  365.  
  366. EXTERN_API_C( void )
  367. getresinfo                        (Handle                 theResource,
  368.                                  short *                theID,
  369.                                  ResType *                theType,
  370.                                  char *                    name);
  371.  
  372. EXTERN_API_C( void )
  373. setresinfo                        (Handle                 theResource,
  374.                                  short                     theID,
  375.                                  const char *            name);
  376.  
  377. EXTERN_API_C( void )
  378. addresource                        (Handle                 theResource,
  379.                                  ResType                 theType,
  380.                                  short                     theID,
  381.                                  const char *            name);
  382.  
  383. #endif  /* CGLUESUPPORTED */
  384.  
  385. #if OLDROUTINENAMES
  386. #define SizeResource(theResource) GetResourceSizeOnDisk(theResource)
  387. #define MaxSizeRsrc(theResource) GetMaxResourceSize(theResource)
  388. #define RmveResource(theResource) RemoveResource(theResource)
  389.  
  390. #endif  /* OLDROUTINENAMES */
  391.  
  392. /*
  393.     These typedefs were originally created for the Copland Resource Mangager
  394. */
  395. typedef short                             ResFileRefNum;
  396. typedef short                             ResID;
  397. typedef short                             ResAttributes;
  398. typedef short                             ResFileAttributes;
  399.  
  400.  
  401.  
  402. #if PRAGMA_STRUCT_ALIGN
  403.     #pragma options align=reset
  404. #elif PRAGMA_STRUCT_PACKPUSH
  405.     #pragma pack(pop)
  406. #elif PRAGMA_STRUCT_PACK
  407.     #pragma pack()
  408. #endif
  409.  
  410. #ifdef PRAGMA_IMPORT_OFF
  411. #pragma import off
  412. #elif PRAGMA_IMPORT
  413. #pragma import reset
  414. #endif
  415.  
  416. #ifdef __cplusplus
  417. }
  418. #endif
  419.  
  420. #endif /* __RESOURCES__ */
  421.  
  422.